const paths = require('./paths');
const path = require('path');
const webpack = require('webpack');
const evn = process.env.NODE_ENV == 'production' ? 'production' : 'development';
module.exports = {
    mode: evn,
    entry: {
        // 定义程序中打包公共文件的入口文件vendor.js
        vendor: ['antd', 'react', 'react-router', 'react-dom'],
    },

    output: {
        path: paths.appPublic,
        filename: 'static/js/[name].js',
        library: '[name]_library',
        chunkFilename: 'static/js/[name].chunk.js',
    },
    
    plugins: [
        new webpack.DllPlugin({
            // 定义程序中打包公共文件的入口文件vendor.js
            context: paths.appPublic,

            // manifest.json文件的输出位置
            path: path.join(paths.appPublic, 'static/js/[name]-manifest.json'),

            // 定义打包的公共vendor文件对外暴露的函数名
            name: '[name]_library'
        })
    ]
};